package rest.jbpm.wrappers.lists;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import rest.jbpm.wrappers.Task;

@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
@XmlType(name = "tasks", propOrder = {
    "tasks"})
public class TaskList {

	private List<Task> tasks;
	private String baseUri;
	
	protected TaskList() {
		
	}
	
	public TaskList(Collection<? extends org.jbpm.api.task.Task> tsks, 
            String baseUri) {
		
		this.baseUri = baseUri;
		tasks = new ArrayList<Task>();
		
		for(org.jbpm.api.task.Task tsk : tsks)
			tasks.add(new Task(tsk,baseUri));

	}
    
    public TaskList(Collection<? extends org.jbpm.api.task.Task> tsks, 
            String baseUri, boolean unwrap) {
		
		this.baseUri = baseUri;
		tasks = new ArrayList<Task>();
		
		for(org.jbpm.api.task.Task tsk : tsks)
			tasks.add(new Task(tsk,baseUri));

	}
	
	@XmlElement(name="task",required=true)
	public List<Task> getTasks() {
		return tasks;
	}
}
